home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / language / modula.zoo / _defn_ex_process.def < prev    next >
Text File  |  1988-04-26  |  3KB  |  89 lines

  1. DEFINITION MODULE Process;       (* G. Koller 29.11.87 *)
  2.  
  3.   FROM SYSTEM IMPORT 
  4.     WORD, ADDRESS;
  5.  
  6.   TYPE
  7.     M68000StatusBits = (
  8.       sbCarry,          (* 0 *)
  9.       sbOverflow,       (* 1 *)
  10.       sbZero,           (* 2 *)
  11.       sbNegativ,        (* 3 *)
  12.       sbExtend,         (* 4 *)
  13.       sbNotUsed5,       (* 5 *)
  14.       sbNotUsed6,       (* 6 *)
  15.       sbNotUsed7,       (* 7 *)
  16.       sbIntMask0,       (* 8 *)
  17.       sbIntMask1,       (* 9 *)
  18.       sbIntMask2,       (* a *)
  19.       sbNotUsed11,      (* b *)
  20.       sbNotUsed12,      (* c *)
  21.       sbSupervisor,     (* d *)
  22.       sbNotUsed13,      (* e *)
  23.       sbTrace           (* f *)
  24.     );
  25.     
  26.     M68000StatusRegister = 
  27.       SET OF M68000StatusBits;
  28.  
  29.     PROCESS = POINTER TO M68000Context;
  30.  
  31.     M68000Context =
  32.       RECORD
  33.         Valid          : LONGINT;               (*  0H BYTE Offset *) (*DS*)
  34.         D0, D1, D2, D3,                         (*  4H *)
  35.         D4, D5, D6, D7 : LONGINT;               (* 14H *)
  36.         A0, A1, A2, A3 : ADDRESS;               (* 24H *)
  37.         ModuleBaseA4   : ADDRESS;               (* 34H *)
  38.         ProcessBaseA5  : ADDRESS;               (* 38H *)
  39.         FramePointerA6 : ADDRESS;               (* 3CH *)
  40.         StackPointerA7 : ADDRESS;               (* 40H *) (*DS*)
  41.         StatusRegister : M68000StatusRegister;  (* 44H *)
  42.         ProgramCounter : PROC;                  (* 46H *)
  43.       END; (* M68000Context *)                  (* 4AH *)
  44.  
  45. (* Only if Valid in M68000Context equals Magic the PROCESS is valid *)
  46.  
  47. CONST
  48.     Magic = 04091964H; 
  49.     
  50.     (* M68000 Stack grows down to lower memory addresses.
  51.        This way, D0 of Context is on top of Stack and A7 of
  52.        the saved Process context must point to this location.
  53.        SavedFramePointer is on bottom of the stack an should 
  54.        be NIL to mark the end of the dynamic link chain 
  55.      *)
  56.  
  57.   VAR
  58.     MainPROCESSPtr : POINTER TO PROCESS;
  59.     (* Pointes to the process variable of the main process.
  60.        If not NIL, the referenced, saved context will be loaded 
  61.        after an error in a coroutine for correct debugger operation.    *)
  62.     ErrorPROCESS : PROCESS;
  63.     (* If there was a valid MainPROCESSPtr the errornouse process 
  64.        context is saved referenced by this location                     *)
  65.     GemSSP : ADDRESS;
  66.     (* Gem System Stack Pointer saved in this location while installing *)
  67.  
  68.   PROCEDURE LISTEN;   
  69.  
  70.   PROCEDURE NEWPROCESS (ProcessCode   : PROC;
  71.                         WorkSpaceBase : ADDRESS;
  72.                         WorkSpaceSize : LONGCARD;
  73.                     VAR ProcessDesc   : PROCESS   );
  74.   (* create a basic process image inside the WorkSpace *)
  75.  
  76.   PROCEDURE TRANSFER   (VAR From: PROCESS; VAR To: PROCESS);
  77.     CODE(04E43H); (*DS*)
  78.   (* transfer the processor control to the context of process To
  79.      an save current context in From. From and To may be equal *)
  80.  
  81.   PROCEDURE IOTRANSFER (VAR From: PROCESS; VAR To: PROCESS; Vector: ADDRESS);
  82.     CODE(04E44H); (*DS*)
  83.   (* transfer the processor control to the context of process To
  84.      an save current context of the interrupt process in From. 
  85.      From context will be loaded in case of an interrupt and the
  86.      running process will be saved under Address To *)
  87.  
  88. END (* OF DEFINITION MODULE *) Process.
  89.